package com.itheima.dao;

import com.itheima.dto.SelectEmpDTO;
import com.itheima.po.*;
import com.itheima.pojo.Emp;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.ArrayList;
import java.util.List;

/**
 *
 */
@Mapper
public interface EmpMapper {

    List<SelectEmpDTO> selectEmp(@Param("p") SelectEmpPageParam param);

    /**
     * 根据id批量删除
     * @param ids
     * @return
     */
    int deleteByIds(List<Integer> ids);

    @Select("select count(*) from emp")
    Integer selectEmpCount(SelectEmpPageParam selectEmpPageParam);

    int addEmp(@Param("e") InsertEmp emp);

    /**
     * 根据id查询
     */
    @Select("select id,phone,username,password,name,gender,image,job,salary,entry_date,dept_id,create_time,update_time from emp where id = #{id}")
    SelectEmpById selectById(Integer id);

    /**
     * 跟新员工信息
     * @param emp
     * @return
     */
    int updateEmp(@Param("e") UpdateEmp emp);

    /**
     * 查询所有员工列表
     * @return
     */
    @Select("select id,username,password,name,gender,image,job,salary,entry_date,dept_id,create_time,update_time from emp")
    List<SelectEmpList> selectAll();

    /**
     * 登录
     */
    @Select("select id,username,password,name from emp where username = #{username}")
    Emp login(String username);

}
